$(function () {

    //隐藏结果展示页面
    $(".show_result").hide()
    //单机启动图片文件上传
    $(".content_btn1").click(function () {
        $(".file_input1").trigger("click");
    })
    $(".content_btn2").click(function () {
        $(".file_input2").trigger("click");
    })

    //是图片框加载为上传的图片
    var img1 = ""
    var img2 = ""
    $(".file_input1").bind("change", function () {
        //拿到文件
         img1 = this.files[0];
        $(".prev_photo1").attr({"src": URL.createObjectURL(img1)});
    })

    $(".file_input2").bind("change", function () {
        //拿到文件
         img2 = this.files[0];
        $(".prev_photo2").attr({"src": URL.createObjectURL(img2)});
    })

    var fileSize1 = "";
    var fileSize2 = "" ;
    //点击传送数据到后台
    $(".btn").bind("click", function () {
         var form = $(".form")[0];
         var formData = new FormData(form);
        fileSize1 = formData.get("file1");
         fileSize2 = formData.get("file2");
        $.ajax({
            url: "face?action=faceDiscern&fileSize1=" + fileSize1.size +"&fileSize2=" +fileSize2.size ,
            type: "post",
            data: formData,
            dataType: "json",
            processData: false,
            contentType: false,
            success: function (data) {
                console.log(data)
                $("#score").html(data.result.score)
                console.log("成功")
                $(".show_result").show()
            },
            error: function (data) {
                console.log("失败")
            }
        })
    })
})